<template>
	<view class="info-content">
		<view class="info-box" v-for="(item,index) in list" :key='index' @click="queryDetail(item)">
			<view class="box-title" >
		<text class="bgcolor" v-if="keys1=='entityType'">{{item.entityType=='DLCG_KB'?'开标结果':'招标任务'}}</text>
		<text>【{{item[keys2]}}】{{item[keys3]}}</text>
			</view>
			<view class="box-footer">
				<view class="box-status"  v-if="keys1=='entityType'" >
					<text>{{item.entityType=='DLCG_KB'?item.kbProcessStatus_dictText:item.processStatus_dictText}}</text>
				</view>
				<view class="box-status"  v-if="keys1==''" >
					<text>{{item.processStatus_dictText}}</text>
				</view>
				<view class="box-time">
					<text>{{item.createTime}}</text>
				</view>
			</view>
		</view>
		 <view class="info-box" style="border:none" v-if="list.length==0">
		 	<view class="box-nofooter" style="text-align: center;line-height: 50rpx;">
		 		没有搜索到数据！
		 	</view>
		 </view>
		 <view class="info-box" style="border:none" v-if="list.length>0" @click="loadMore">
		 	  <view class="box-nofooter" style="text-align: center;line-height: 50rpx;">
		 	  	{{total>list.length?'点击加载更多！':'已经到底了啦！'}}
		 	  </view>
		 </view>
		
	</view>
</template>

<script>
	import {queryAppProInfo} from '../../api/service.js'
	export default{
		props:{
			url:{
				type:String,
				default:''
			},
			currentType:{
				type:Number,
				default:0
			},
			data:{
				type:Object,
				default:function(){
					return {
					 keys1:'',
				     keys2:'purCode',
					 keys3:'purName',
					 keys4:'processStatus_dictText',
					 keys5:'updateTime'
					}
				}
			},
			type:{
				type:String,
				default:'cg'
			}
		},
		watch:{
			url(newdt,olddt){
			 this.queryParam.pageNo=1,
			 this.queryParam.pageSize=10;
			 this.currentPageNo=1;
			 this.list=[];
			 this.keys1=this.data.keys1;
			  this.keys2=this.data.keys2;
			   this.keys3=this.data.keys3; 
			   this.keys4=this.data.keys4;
			    this.keys5=this.data.keys5;
			 this.getAppProInfo();
			 
			}
		},
		
		data(){
			return {
				keys1:this.data.keys1,
				keys2:this.data.keys2,
			    keys3:this.data.keys3,
				keys4:this.data.keys4,
				keys5:this.data.keys5,
				list:[],
				total:0,
				currentPageNo:1,
				queryParam:{
				pageNo:1,
				pageSize:10
				}
			}
		},
		created() {
			this.queryParam.pageNo=1,
			this.queryParam.pageSize=10;
			this.currentPageNo=1;
			this.getAppProInfo();
		},
		mounted() {
			var _this=this;
			uni.$on('updateProInfo',function(data){
				 _this.getAppProInfo();
			        console.log('监听到事件来自 update ，携带参数 msg 为：' + data.msg);
			    })
		},
		methods:{
		 	getAppProInfo(){
				uni.showLoading({
				    title: '数据加载中'
				});
				
				console.log(this.data)
				queryAppProInfo(this.url,{
				pageNo:this.queryParam.pageNo,
				pageSize:this.queryParam.pageSize,
				current:1
			}).then(res=>{
				// setTimeout(()=>{
					 uni.hideLoading();
				// },800)
				
				if(res.success){
					this.list=res.result.records;
					this.total=res.result.total;
				}else{
				 uni.showToast({
				 	title:"数据加载失败！",
					duration:2000
				 })	
				}
			})
			},
			// 记录每次加载记录页数，加载更多数据
			loadMore(){
				// 数据待到总数一致时候停止在加载
				if(this.list.length>=this.total){
					// uni.
				}else{
					this.currentPageNo++;
					this.queryParam.pageSize=this.currentPageNo*10
					this.getAppProInfo()
				}
			},
			// 不同的模块 各自跳转到业务模块详情
			queryDetail(item){
			
				if(this.type=='cg'){
				 uni.navigateTo({
				 	url:'../component/purchaseDetail?id='+item.id+'&processId='+item.processId+'&status='+item.processStatus+"&stype="+this.currentType,
				 })
				}
				if(this.type=='dl'){
					  let status= item.entityType=='DLCG'?item.processStatus:item.kbProcessStatus;
					  let processId= item.entityType=='DLCG'?item.processId:item.kbProcessId;
					     // path: `/tender/detailTenderAgent/${item.cgId}/${processId}/${item.id}/${entityType}/${item.entityType}`
					uni.navigateTo({
						url:'../component/dpurchaseDetail?id='+item.id+'&cgId='+item.cgId+'&processId='+processId+'&status='+status+'&type='+item.entityType+"&stype="+this.currentType,
					})
				}
				
				if(this.type=='ht'){
				 uni.navigateTo({
				 	url:'../component/contractDetail?id='+item.id+'&processId='+item.processId+'&status='+item.processStatus+'&cgId='+item.cgId+"&stype="+this.currentType,
				 })
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.info-content{
		width: 100%;
		height: auto;
		position: relative;
		.info-box{
			display: flex;
			flex-direction:column;
			justify-content: center;
			padding: 18rpx 22rpx;
			border-bottom: 2rpx solid #F7F4F4;
			.box-title{
				flex: 1;
				padding:12rpx 0rpx 10rpx;
				font-size:28rpx;
				font-family:PingFangSC-Regular,PingFang SC;
				font-weight:400;
				color:#333333;
				line-height: 40rpx;
				text{
					vertical-align: middle;
				}
				.bgcolor{
					background: #FDE7D2;
					color:#A07C5A;
					display: inline-block;
					padding: 0 10rpx;
					border-radius: 4rpx;
					font-size:22rpx;
					line-height: 32rpx;
					font-family:PingFangSC-Regular,PingFang SC;
					font-weight:400;
					text-align: center;
				}
			}
			.box-footer{
				display: flex;
				flex: 1;
				flex-direction: row;
				justify-content: flex-start;
				font-size:26rpx;
				font-family:PingFangSC-Regular,PingFang SC;
				font-weight:400;
				color:#999999;
				.box-status{
					flex: 1;
				}
				.box-time{
					flex: 1;
					text-align: right;
					font-size:22rpx;
				}
				
			}
		}
	}
	
</style>
